
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:smart_home/model/my_device.dart';

Future<String> _loadMyDevice() async{
  return rootBundle.loadString("static/data/my_device.json");
}

Future<List<MyDevice>> decodeMyDevice() async {
  String myDeviceJson = await _loadMyDevice();
  List jsonList = json.decode(myDeviceJson);
  List<MyDevice> myDeviceList = [];

  for(var i = 0; i < jsonList.length; i++){
    MyDevice myDeviceItem = MyDevice.fromJson(jsonList[i]);
    myDeviceList.add(myDeviceItem);
  }


  return myDeviceList;

}